﻿function callAjaxGetSuatChieu(abc) {
    if (abc.checked) {
        var value = abc.value;
        var lstPhim = new Array();
        lstPhim = document.getElementsByName("select_phim");
        var f_checked = "";
        for (var i = 0; i < lstPhim.length; i++) {
            var item = lstPhim.item(i);
            if (item.checked) {
                if (item.value == '0') {
                    for (var j = 0; j < lstPhim.length; j++) {
                        var film = lstPhim.item(j);
                        if (film.value != '0') {
                            f_checked += film.value + ",";
                        }

                    }
                    break;
                }
                else {
                    f_checked += item.value + ",";
                }
            }
        }
        var strURL = "Ajax/ajax_film_schedule.aspx?" + "ngay=" + value + "&phim=" + f_checked;
        funcAJAX_GET("present", strURL);
    }
    else {
        document.getElementById("present").innerHTML = "";
    }
}

var maVe = null;
function select_seat(abc) {
    if (abc.src.indexOf("img/seat_0.gif", 0) != -1) {
        if (maVe == null) {
            abc.src = abc.src.replace("img/seat_0.gif", "img/seat_5.gif");
            maVe = abc.alt;
        }

    }
    else {
        abc.src = abc.src.replace("img/seat_5.gif", "img/seat_0.gif");
        maVe = null;
    }
}

function check_login() {
    var username = document.getElementById("txt_username").value;
    var password = document.getElementById("txt_password").value;

    callAjaxCheckLogin(username, password);
}

function callAjaxCheckLogin(username, password) {
    var strURL = "Ajax/ajax_login.aspx?" + "username=" + username + "&password=" + password + "&ve=" + maVe;
    if (maVe == null) {
        alert('Bạn chưa chọn ghế');
    }
    else
        funcAJAX_GET("notice", strURL);
}

jQuery(function ($) {
    // Load dialog on page load
    //$('#basic-modal-content').modal();

    // Load dialog on click
    $('.basic').click(function (e) {
        var strURL = "Ajax/ajax_choose_seat.aspx";
        $('#basic-modal-content').modal();
        funcAJAX_GET("basic-modal-content", strURL);
        return false;
    });
});

function drop(abc) {
    var ticket = abc.title;
    window.location = "personalize.aspx?drop=1&id=" + ticket;
}

function success() {
    alert("Đăng kí thành công");
    window.location = "personalize.aspx";
}

function updatefare(abc) {
    var maLoaiVe = abc.title;
    var id = "fare" + maLoaiVe;
    var giaVeMoi = document.getElementById(id).value;
    var url = "personalize.aspx?maloaive=" + maLoaiVe + "&giavemoi=" + giaVeMoi;
    window.location = url;
}

function updatepromotion(abc) {
    var makm = abc.title;
    var id = "promotion" + makm;
    var tlgm = document.getElementById(id).value;
    var url = "personalize.aspx?makm=" + makm + "&tlgm=" + tlgm;
    window.location = url;
}

function insert_schedule(abc) {
    var mphim = document.getElementById("tbt_MaPhim_Insert_Schedule").value;
    var mphong = document.getElementById("tbt_MaPhongChieu_Insert_Schedule").value;
    var tgbd = document.getElementById("tbt_ThoiGianBatDau_Insert_Schedule").value;
    var tgkt = document.getElementById("tbt_ThoiGianKetThuc_Insert_Schedule").value;
    var slv = document.getElementById("tbt_SoLuongVe_Insert_Schedule").value;
    var url = "personalize.aspx?mphim=" + mphim + "&mphong=" + mphong + "&tgbd=" + tgbd + "&tgkt=" + tgkt + "&slv=" + slv;
    window.location = url;
}